package flexcommon.tests.utils
{
	import flexunit.framework.Assert;
	import flexunit.framework.TestCase;
	
	import flexcommon.utils.CharacterUtils;

	/**
	 * @private
	 */
	public class TestCharacterUtils extends TestCase
	{
		public function TestCharacterUtils(methodName:String=null)
		{
			super(methodName);
		}
		
		public override function setUp():void {
	    	
	  }
		
		public function testIsControl():void 
		{
      try {
      	Assert.assertEquals( true, CharacterUtils.isControl( "\t" ) );
      	Assert.assertEquals( false, CharacterUtils.isControl( "A" ) );
      }
      catch( e:Error ) {
      	trace( "testIsControl >> " + e.getStackTrace() );
      	fail( "testIsControl failed: " + e.message );
      }
    }
    
    public function testIsSpace():void 
    {
      try {
        Assert.assertEquals( false, CharacterUtils.isSpace( "\r" ) );
        Assert.assertEquals( true, CharacterUtils.isSpace( " " ) );
        Assert.assertEquals( false, CharacterUtils.isSpace( "A" ) );
      }
      catch( e:Error ) {
        trace( "testIsSpace >> " + e.getStackTrace() );
        fail( "testIsSpace failed: " + e.message );
      }
    }
	    
	  public function testIsWhiteSpace():void 
		{
      try {
      	Assert.assertEquals( true, CharacterUtils.isWhiteSpace( "\r" ) );
      	Assert.assertEquals( true, CharacterUtils.isWhiteSpace( " " ) );
      	Assert.assertEquals( false, CharacterUtils.isWhiteSpace( "A" ) );
      }
      catch( e:Error ) {
      	trace( "testIsWhiteSpace >> " + e.getStackTrace() );
      	fail( "testIsWhiteSpace failed: " + e.message );
      }
    }
	    
	  public function testIsPunctuation():void 
		{
      try {
      	Assert.assertEquals( true, CharacterUtils.isPunctuation( "$" ) );
      	Assert.assertEquals( true, CharacterUtils.isPunctuation( ";" ) );
      	Assert.assertEquals( true, CharacterUtils.isPunctuation( "[" ) );
      	Assert.assertEquals( true, CharacterUtils.isPunctuation( "|" ) );
      	Assert.assertEquals( false, CharacterUtils.isPunctuation( "A" ) );
      }
      catch( e:Error ) {
      	trace( "testIsPunctuation >> " + e.getStackTrace() );
      	fail( "testIsPunctuation failed: " + e.message );
      }
    }
	    
	  public function testIsAlphabetic():void 
		{
      try {
      	Assert.assertEquals( true, CharacterUtils.isAlphabetic( "A" ) );
      	Assert.assertEquals( true, CharacterUtils.isAlphabetic( "Z" ) );
      	Assert.assertEquals( true, CharacterUtils.isAlphabetic( "a" ) );
      	Assert.assertEquals( true, CharacterUtils.isAlphabetic( "z" ) );
      	Assert.assertEquals( false, CharacterUtils.isAlphabetic( "[" ) );
      }
      catch( e:Error ) {
      	trace( "testIsAlphabetic >> " + e.getStackTrace() );
      	fail( "testIsAlphabetic failed: " + e.message );
      }
    }
	    
	  public function testIsAlphaNumeric():void 
		{
      try {
      	Assert.assertEquals( true, CharacterUtils.isAlphaNumeric( "A" ) );
      	Assert.assertEquals( true, CharacterUtils.isAlphaNumeric( "Z" ) );
      	Assert.assertEquals( true, CharacterUtils.isAlphaNumeric( "0" ) );
      	Assert.assertEquals( true, CharacterUtils.isAlphaNumeric( "9" ) );
      	Assert.assertEquals( false, CharacterUtils.isAlphaNumeric( "[" ) );
      	Assert.assertEquals( false, CharacterUtils.isAlphaNumeric( "\t" ) );
      }
      catch( e:Error ) {
      	trace( "testIsAlphaNumeric >> " + e.getStackTrace() );
      	fail( "testIsAlphaNumeric failed: " + e.message );
      }
    }
	    
	  public function testIsNumeric():void 
		{
      try {
      	Assert.assertEquals( false, CharacterUtils.isNumeric( "A" ) );
      	Assert.assertEquals( false, CharacterUtils.isNumeric( "Z" ) );
      	Assert.assertEquals( true, CharacterUtils.isNumeric( "0" ) );
      	Assert.assertEquals( true, CharacterUtils.isNumeric( "9" ) );
      	Assert.assertEquals( false, CharacterUtils.isNumeric( "[" ) );
      	Assert.assertEquals( false, CharacterUtils.isNumeric( "\t" ) );
      }
      catch( e:Error ) {
      	trace( "testIsNumeric >> " + e.getStackTrace() );
      	fail( "testIsNumeric failed: " + e.message );
      }
    }		
	}
}